package com.myapp.ruyixing.http;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import com.myapp.ruyixing.model.FansList;
import com.myapp.ruyixing.model.FansList.Fans;

public class FansListParser extends RYJSONParser {
	@Override
	public Object parse(JSONObject jsonObject) {
		FansList fansList = new FansList();

		ListModelParser.parseListModel(fansList, jsonObject);
		JSONObject data = jsonObject.optJSONObject("data");
		JSONArray array = data.optJSONArray("items");
		fansList.items = new ArrayList<FansList.Fans>();
		for (int i = 0; array != null && i < array.length(); i++) {
			JSONObject object = array.optJSONObject(i);
			if (object != null) {
				Fans fans = new Fans();
				fans.picurl = object.optString("picurl", "");
				fans.score = object.optString("score", "");
				fans.userid = object.optString("userid", "");
				fans.username = object.optString("username", "");
				fansList.items.add(fans);
			}
		}

		return fansList;

	}
}
